package selcoursesys.dao.impl;

import db.MyHibernateSessionFactory;
import org.hibernate.Query;
import org.hibernate.Session;
import selcoursesys.dao.SearchDao;
import selcoursesys.entity.CourseEntity;
import selcoursesys.entity.MajorEntity;

import java.util.List;

/**
 * Created by Lpbdz on 2017/4/11.
 */
public class SearchDaoImpl implements SearchDao{
    public List<CourseEntity> searchInfo(String cid, String keyword,String term){
        Session session= MyHibernateSessionFactory.getSession();
        session.clear();
        String hql="From CourseEntity course where course.courseid like ? and course.coursename like ?";
        Query query=session.createQuery(hql);
        query.setString(0,("%"+cid+term+"%"));
        query.setString(1,"%"+keyword+"%");
        List list=query.list();
        return list;
    }
}
